﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="mtaotsused_otsus", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(MtaotsusedOtsus))]
    public class MtaotsusedOtsusSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMtaotsusedOtsus clazz;
        
        public MtaotsusedOtsusSerializer(IMtaotsusedOtsus clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("otsuse_id");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.OtsuseId))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("ark");
            if (clazz.Ark!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Ark))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("otsuse_liik");
            if (clazz.OtsuseLiik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OtsuseLiik))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("otsuse_nr");
            if (clazz.OtsuseNr!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OtsuseNr))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("piirkond");
            if (clazz.Piirkond!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Piirkond))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("otsuse_olek");
            if (clazz.OtsuseOlek!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OtsuseOlek))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("otsuse_kpv");
            if (clazz.OtsuseKpv!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.OtsuseKpv))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("lisatahtaeg");
            if (clazz.Lisatahtaeg!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Lisatahtaeg))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("kandeliik");
            if (clazz.Kandeliik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Kandeliik))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("joust");
            if (clazz.Joust!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Joust))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("joust_kpv");
            if (clazz.JoustKpv!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.JoustKpv))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("paevik_id");
            if (clazz.PaevikId!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.PaevikId))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("maj_paevik_id");
            if (clazz.MajPaevikId!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.MajPaevikId))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("muutus");
            if (clazz.Muutus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Muutus))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("mkuup");
            if (clazz.Mkuup!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Mkuup))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="otsuse_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaotsused_otsus>otsuse_id");
                }
                clazz.OtsuseId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("otsuse_id")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaotsused_otsus>otsuse_id", Reader.LocalName);
            }
            if (Reader.LocalName=="ark") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Ark = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("ark")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaotsused_otsus>ark", Reader.LocalName);
            }
            if (Reader.LocalName=="otsuse_liik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.OtsuseLiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("otsuse_liik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaotsused_otsus>otsuse_liik", Reader.LocalName);
            }
            if (Reader.LocalName=="otsuse_nr") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.OtsuseNr = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("otsuse_nr")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaotsused_otsus>otsuse_nr", Reader.LocalName);
            }
            if (Reader.LocalName=="piirkond") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Piirkond = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("piirkond")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaotsused_otsus>piirkond", Reader.LocalName);
            }
            if (Reader.LocalName=="otsuse_olek") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.OtsuseOlek = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("otsuse_olek")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaotsused_otsus>otsuse_olek", Reader.LocalName);
            }
            if (Reader.LocalName=="otsuse_kpv") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.OtsuseKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("otsuse_kpv")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaotsused_otsus>otsuse_kpv", Reader.LocalName);
            }
            if (Reader.LocalName=="lisatahtaeg") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Lisatahtaeg = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("lisatahtaeg")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaotsused_otsus>lisatahtaeg", Reader.LocalName);
            }
            if (Reader.LocalName=="kandeliik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Kandeliik = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("kandeliik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaotsused_otsus>kandeliik", Reader.LocalName);
            }
            if (Reader.LocalName=="joust") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Joust = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("joust")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaotsused_otsus>joust", Reader.LocalName);
            }
            if (Reader.LocalName=="joust_kpv") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.JoustKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("joust_kpv")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaotsused_otsus>joust_kpv", Reader.LocalName);
            }
            if (Reader.LocalName=="paevik_id") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.PaevikId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("paevik_id")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaotsused_otsus>paevik_id", Reader.LocalName);
            }
            if (Reader.LocalName=="maj_paevik_id") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MajPaevikId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("maj_paevik_id")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaotsused_otsus>maj_paevik_id", Reader.LocalName);
            }
            if (Reader.LocalName=="muutus") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Muutus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("muutus")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaotsused_otsus>muutus", Reader.LocalName);
            }
            if (Reader.LocalName=="mkuup") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Mkuup = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("mkuup")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaotsused_otsus>mkuup", Reader.LocalName);
            }
        }
    }
}
